<template>
  <div>
    <ul>
      <!-- <li v-for="user in users" :key="user.id">{{ user.name }}</li> -->
    </ul>
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      users: [], // 存储从API获取的用户数据
    };
  },
  created() {
    this.fetchUsers(); // 在组件创建时获取用户数据
  },
  methods: {
    fetchUsers() {
      axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";
      axios
        .post("http://localhost:9201/workOrder/getWorkOrderByPage", {
          total: 5,
          pageSize: 10,
          currentPage: 1,
        }) // 替换为你的API端点地址和端口号
        .then((response) => {
          console.log(response, "+===>this.users====");
          this.users = response.data; // 将获取的数据赋值给users数组
        })
        .catch((error) => {
          console.error("There was an error!", error); // 处理错误情况
        });
    },
  },
};
</script>
